<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#finance_line'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['list'];?></span></a>
				</li>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-5">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-list"></i> <?php echo $this->language['detail'];?></div>
				</div>
				<div class="panel-body">
					<form action="javascript:updateLine(<?php echo $this->line['line_id'];?>);">
						<ul class="list-group">
							<li class="list-group-item">
								<b><?php echo $this->language['bussiness_name'];?></b>
								<span class="pull-right"><?php echo $this->line['line_name'];?></span>
							</li>
							<li class="list-group-item">
								<b><?php echo $this->language['bussiness_prefix'];?></b>
								<span class="pull-right"><?php echo $this->line['line_prefix'];?></span>
							</li>
							<li class="list-group-item">
								<b><?php echo $this->language['note'];?></b>
								<span class="pull-right"><?php echo $this->line['line_description'];?></span>
							</li>
							<li class="list-group-item">
								<b><?php echo $this->language['bussiness_leader'];?></b>
								<span class="pull-right">
									<select id='uynhiem' class='form-control'>
									<?php foreach($_SESSION['room_data'] as $room):?>
										<optgroup label="<?php echo $room['room_name'];?>">
											<?php foreach($room['users'] as $user):?>
											<option value="<?php echo $user['user_id'];?>" <?php echo ($this->line['line_user_id'] == $user['user_id']) ? 'selected' : '';?>><?php echo $user['user_fullname'];?></option>
											<?php endforeach;?>
										</optgroup>
										<?php endforeach;?>
									</select>
								</span>
								<div class="clear"></div>
							</li>
							<li class="list-group-item">
								<b><?php echo $this->language['bussiness_request_created'];?></b>
								<span class="pull-right"><?php echo count($this->requests);?></span>
							</li>
							<?php if(check_permission('bussiness_edit')){ ?>
							<li class="list-group-item">
								<b>&nbsp;</b>
								<span class="pull-right"><button class="btn btn-primary" type="submit"><?php echo $this->language['update'];?></button></span>
							</li>
							<?php } ?>
						</ul>
					</form>
				</div>
			</div>
		</div>
		<div class="col-lg-7">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-list"></i> Phân nhóm trong Ngành</div>
				</div>
				<div class="panel-body">
					<table class="table table-hover table-condensed">
						<thead>
							<tr>
								<th width="30px">STT</th>
								<th>Tên nhóm</th>
								<th width="120px">Phần trăm Lương</th>
								<th width="30px"></th>
							</tr>
						</thead>
						<tbody>
							<?php $stt = 0;foreach($this->groups as $row){ $stt++;?>
							<tr>
								<td><?php echo $stt;?></td>
								<td><?php echo $row['group_name'];?></td>
								<td class="text-center"><?php echo $row['group_percent'];?> %</td>
								<td>
									<a href='javascript:;' onClick="if(confirm('Are you Sure?')){deleteTGroup(<?php echo $row['group_id'];?>);};" ><img src='resources/images/icons/cross.png' alt='Xóa nhóm' /></a>
								</td>
							</tr>
							<?php } ?>
						</tbody>
					</table>
					<button class="btn btn-danger" data-toggle="modal" href="#group_create"><i class="icon-plus"></i> Thêm nhóm</button>
				</div>
			</div>
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-list"></i> <?php echo $this->language['bussiness_request_created'];?></div>
				</div>
				<div class="panel-body">
					<table class="table table-hover table-condensed">
						<thead>
							<tr>
								<th width="70px"><?php echo $this->language['code'];?></th>
								<th><?php echo $this->language['reason'];?></th>
								<th width="120px"><?php echo $this->language['creator'];?></th>
								<th width="90px"><?php echo $this->language['create_date'];?></th>
								<th width="90px"><?php echo $this->language['status'];?></th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($this->requests as $row){ ?>
							<tr>
								<td><a href='#request_view/id=<?php echo $row['req_id'];?>'><?php echo $row['req_code'];?></a></td>
								<td><a href='#request_view/id=<?php echo $row['req_id'];?>'><?php echo $row['req_reason'];?></a></td>
								<td><?php echo $_SESSION['user_data'][$row['user_id']]['fullname'];?></td>
								<td><?php echo date("d/m/Y",$row['req_date']);?></td>
								<td><?php
								if($row['req_signature1']=='1') echo "<font color=green>".$this->language['approved']."</font>";
								else echo "<font color=red>".$this->language['un_approve']."</font>";
								?></td>
							</tr>
							<?php } ?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="group_create">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:createTGroup();">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">Tạo nhóm mới</h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label for="noteTitle">Tên nhóm</label>
								<input type="text" class="form-control" id="group_name" placeholder="Tên nhóm" />
							</div>
							<div class="form-group">
								<label for="noteTitle">Phần trăm</label>
								<input type="text" class="form-control" id="group_percent" placeholder="Phần trăm" />
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="hidden" id="type_group_create" value="<?php echo $this->line['line_id'];?>" />
						<input type="submit" class="btn btn-primary" value="Đồng ý" />
					</div>
				</form>
			</div>
		</div>
	</div>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>